#ifndef _martice_h
#define _martice_h

#include "ration.h"

class matrix_t
{
private:
    size_t _rows;
    size_t _cols;
    ration_t *data = nullptr;

public:
    matrix_t(size_t rows = 0, size_t cols = 0);
    ~matrix_t();

    ration_t &operator()(size_t i, size_t j);
    ration_t &operator[](size_t index);

    void swap_rows(size_t r1, size_t r2);
    void swap_cols(size_t c1, size_t c2);
    void add_row(size_t r1, size_t r2, const ration_t &scale = 1);
    void add_col(size_t c1, size_t c2, const ration_t &scale = 1);
    void scale_row(size_t r, const ration_t &scale = 1);
    void scale_col(size_t c, const ration_t &scale = 1);

    size_t get_rows();
    size_t get_cols();

    std::string to_latex();

    friend istream &operator>>(istream &in, matrix_t &me);
    friend ostream &operator<<(ostream &out, matrix_t &me);

private:
    size_t __get_pos(size_t i, size_t j);
};
#endif //_martice_h